from google.appengine.ext import db

class Transaction(db.Model):
    ctime = db.DateTimeProperty(auto_now_add=True)
    mtime = db.DateTimeProperty(auto_now_add=True)
    status = db.StringProperty()
    description = db.StringProperty()
    owner = db.UserProperty()
    
class SqlRequest(db.Model):
    transaction_ref = db.ReferenceProperty(Transaction)
    ctime = db.DateTimeProperty(auto_now_add=True)
    mtime = db.DateTimeProperty(auto_now_add=True)
    status = db.StringProperty()
    sql = db.StringProperty()
    description = db.StringProperty()
    owner = db.UserProperty()
    


class Email(db.Model):
    '''
    save all the notification emails sent from iformbuilder
    '''
    ctime = db.DateTimeProperty(auto_now_add=True)
    plaintext_content = db.TextProperty()
    html_content = db.TextProperty()
    sender = db.StringProperty()
    to = db.StringProperty()
    cc = db.StringProperty()
    subject = db.StringProperty()
    date = db.StringProperty()

    
    

class IformDatabaseLog(db.Model):
    '''
    log the failed activities of downloading data from iform database
    '''
    ctime = db.DateTimeProperty(auto_now_add=True)
    mtime = db.DateTimeProperty(auto_now_add=True)
    table = db.StringProperty()
    status = db.StringProperty()
    description = db.StringProperty()
    user = db.UserProperty()    

